home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KoGlobal.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  3.6 KB  |  108 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
  3.    Copyright 2002, 2003 David Faure <faure@kde.org>
  4.    Copyright 2003 Nicolas GOUTTE <goutte@kde.org>
  5.  
  6.    This library is free software; you can redistribute it and/or
  7.    modify it under the terms of the GNU Library General Public
  8.    License as published by the Free Software Foundation; either
  9.    version 2 of the License, or (at your option) any later version.
  10.  
  11.    This library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.    Library General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU Library General Public License
  17.    along with this library; see the file COPYING.LIB.  If not, write to
  18.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.  * Boston, MA 02110-1301, USA.
  20. */
  21.  
  22. #ifndef koGlobal_h
  23. #define koGlobal_h
  24.  
  25. #include <qstringlist.h>
  26. #include <qfont.h>
  27. #include <qmap.h>
  28. class KConfig;
  29.  
  30. #include <koffice_export.h>
  31. class KOFFICECORE_EXPORT KoGlobal
  32. {
  33. public:
  34.     /// For KoApplication
  35.     static void initialize()  {
  36.         (void)self(); // I don't want to make KGlobal instances public, so self() is private
  37.     }
  38.     /**
  39.      * Return the default font for KOffice programs.
  40.      * This is (currently) the same as the KDE-global default font,
  41.      * except that it is guaranteed to have a point size set,
  42.      * never a pixel size (see @ref QFont).
  43.      */
  44.     static QFont defaultFont()  {
  45.         return self()->_defaultFont();
  46.     }
  47.  
  48.     /**
  49.      * @return the global KConfig object around kofficerc.
  50.      * kofficerc is used for KOffice-wide settings, from totally unrelated classes,
  51.      * so this is the centralization of the KConfig object so that the file is
  52.      * parsed only once
  53.      */
  54.     static KConfig* kofficeConfig() {
  55.         return self()->_kofficeConfig();
  56.     }
  57.  
  58.     static int dpiX() {
  59.         return self()->m_dpiX;
  60.     }
  61.     static int dpiY() {
  62.         return self()->m_dpiY;
  63.     }
  64.     /// @internal, for KoApplication
  65.     static void setDPI( int x, int y );
  66.  
  67.     /// Return the list of available languages, in their displayable form
  68.     /// (translated names)
  69.     static QStringList listOfLanguages() {
  70.         return self()->_listOfLanguages();
  71.     }
  72.     /// Return the list of available languages, in their internal form
  73.     /// e.g. "fr" or "en_US", here called "tag"
  74.     static QStringList listTagOfLanguages() { // TODO rename to listOfLanguageTags
  75.         return self()->_listOfLanguageTags();
  76.     }
  77.     /// For a given language display name, return its tag
  78.     static QString tagOfLanguage( const QString & _lang );
  79.     /// For a given language tag, return its display name
  80.     static QString languageFromTag( const QString &_lang );
  81.  
  82.     ~KoGlobal();
  83.  
  84. private:
  85.     static KoGlobal* self();
  86.     KoGlobal();
  87.     QFont _defaultFont();
  88.     QStringList _listOfLanguages();
  89.     QStringList _listOfLanguageTags();
  90.     KConfig* _kofficeConfig();
  91.     void createListOfLanguages();
  92.  
  93.     int m_pointSize;
  94.     typedef QMap<QString, QString> LanguageMap;
  95.     LanguageMap m_langMap; // display-name -> language tag
  96.     KConfig* m_kofficeConfig;
  97.     int m_dpiX;
  98.     int m_dpiY;
  99.     // No BC problem here, constructor is private, feel free to add members
  100.  
  101.     // Singleton pattern. Maybe this should even be refcounted, so
  102.     // that it gets cleaned up when closing all koffice parts in e.g. konqueror?
  103.     static KoGlobal* s_global;
  104.     friend class this_is_a_singleton; // work around gcc warning
  105. };
  106.  
  107. #endif // koGlobal
  108.